package cn.iocoder.yudao.module.cms.keyword.dal.mysql;

import cn.iocoder.yudao.framework.business.basic.dao.mapper.CoreMapper;
import cn.iocoder.yudao.framework.business.basic.dao.query.CoreLambdaQueryWrapper;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.cms.keyword.dal.dataobject.KeywordDO;
import cn.iocoder.yudao.module.cms.keyword.vo.KeywordPageReqVO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 搜索词 Mapper
 *
 * @author 山野羡民（1032694760@qq.com）
 */
@Mapper
public interface KeywordMapper extends CoreMapper<KeywordDO> {

    default PageResult<KeywordDO> selectPage(KeywordPageReqVO reqVO) {
        return selectPage(reqVO, new CoreLambdaQueryWrapper<KeywordDO>()
                .eqIfPresent(KeywordDO::getType, reqVO.getType())
                .likeIfPresent(KeywordDO::getContent, reqVO.getKeyword())
                .eqIfPresent(KeywordDO::getIsHot, reqVO.getIsHot())
                .orderByAsc(KeywordDO::getType)
                .orderByDesc(KeywordDO::getId));
    }

}
